package com.albert.hippo;

import com.albert.hippo.mapper.UserBaseMapper;
import com.albert.hippo.mapper.WXUserMapper;
import com.albert.hippo.model.UserBase;
import com.albert.hippo.model.WXUser;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * *  Author:zlf
 * *  2020/9/29 10:55
 **/
@Service
public class InitService {
    @Autowired
    WXUserMapper wxUserMapper;
    @Autowired
    UserBaseMapper userBaseMapper;

    @PostConstruct
    public void execSql() {
        System.out.println("=================启动执行======================");

        try {
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("user_code", "18831120114");
            UserBase userBase = userBaseMapper.selectOne(queryWrapper);
            System.out.println("========执行结果======" + userBase.getUserName());
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("userbase异常了，异常信息：" + e.getMessage());
        }

        try {

            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("UserId", 12660);
            WXUser wxUser = wxUserMapper.selectOne(queryWrapper);
            System.out.println("========执行结果======" + wxUser.getwXOpenID());
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Wxuser异常了，异常信息：" + e.getMessage());
        }
    }
}
